<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="jt.classic.system.group.IGroup"%>
<%@ page import="jt.classic.system.user.IUser"%>
<%@ page import="org.limp.mine.Label"%>
<%@ page import="org.limp.mine.HTMLTool"%>
<%@ page import="org.limp.mine.Controller"%>
<%@ page import="org.limp.mine.DateTrimmer"%>
<%@ page import="jt.classic.system.wordbook.XWordbook"%>
<%
	String context = jt.classic.system.ISystem.getContextPath();
	Object[] result = (Object[]) request.getAttribute("result");
	Label label = (Label) result[1];
	Controller controller = (Controller) result[2];
	String pageNO = (String) result[3];
	List resultList = (List) result[0];

	Map query = (Map) request.getAttribute("query");

	List list = (List) request.getAttribute("list");

	/*列表类型*/
	String listtype = "directory";//(String)request.getAttribute("listtype");

	String qname = (String) query.get("qname");
	String qtype = (String) query.get("qtype");
	String qdirec = (String) query.get("qdirec");
	String qdirecid = (String) query.get("qdirecid");
	String qstatus = (String) query.get("qstatus");
	String qdate = (String) query.get("qdate");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>信息评论审核列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<jsp:include page="../head.jsp"></jsp:include>
<link rel="stylesheet" type="text/css" href="<%=context%>/app/info/css/directree.css" />
<script type="text/javascript" src="<%=context%>/app/info/js/lanmuselect.js"></script>
<script language="javascript">
  var chk = false;
  function checkall(thizz){
    var chks = document.getElementsByTagName("input");
    for(var i=0;i<chks.length;i++){
      if(chks[i].type == "checkbox"){
        chks[i].checked = !chk;
      }
    }
    
    chk = !chk;
  }
  
  function handleDelete(){
    var rnt = false;
    var ids = "";
    var chks = document.getElementsByTagName("input");
    for(var i=0;i<chks.length;i++){
      if(chks[i].type == "checkbox" && chks[i].checked){
        rnt = true;
        ids += chks[i].value + ",";
      }
    }
    
    if(!rnt){
      alert("请选择要删除信息");
    }else if(confirm("删除信息")){
      createHidden("ids",ids.substring(0,ids.length - 1));
      document.form1.action = "<%=context%>/app/inforeplysh.do?method=delete";
      document.form1.submit();
    }
  }
  
  function handleOK(id, ifid){
       var rnt = false;
	    var ids = "";
	    var ifids = "";
	    
	    if(id){
	    	rnt = true;
	        ids = id + ",";
	        ifids = ifid + ","
	    }else{
		    var chks = document.getElementsByTagName("input");
		    for(var i=0;i<chks.length;i++){
			      if(chks[i].type == "checkbox" && chks[i].checked){
			        rnt = true;
			        ids += chks[i].value + ",";
			        ifids += chks[i].getAttribute("ifid") + ",";
			      }
		    }
	    }
	   
	    if(!rnt){
	      	  alert("请选择审核通过的信息");
	    }else if(confirm("确定审核通过")){
		      createHidden("ids", ids.substring(0,ids.length - 1));
		      createHidden("ifids",ifids.substring(0,ifids.length - 1));
		      
		      Ext.MessageBox.wait('提交处理过程中...');   
		      Ext.Ajax.request({       
			        //请求地址       
			       url: context + "/app/inforeplysh.do?method=approve",       
			       //提交参数组       
			       fileUpload: true,   
			       form: 'form2',   
			       scope: 'form2',     
			       //成功时回调       
			       success: function(response, options) {       
			           //获取响应的json字符串        
			           Ext.MessageBox.hide();
			           
			           var json = response.responseText;    
	                   var o = Ext.util.JSON.decode(json);
			           
			           if (o.success) {
						   alert("评论审核通过!");
						   handleRefresh();
	                   }else{
			               Ext.Msg.alert('提示', '提交审核失败!'); 
			           }                
			       }      
		     }); 
	    }
  }
  
  function handleKO(id, ifid){
      var rnt = false;
	    var ids = "";
	    var ifids = "";
	    if(id){
	    	rnt = true;
	        ids = id + ",";
	        ifids = ifid + ",";
	    }else{
		    var chks = document.getElementsByTagName("input");
		    for(var i=0;i<chks.length;i++){
			      if(chks[i].type == "checkbox" && chks[i].checked){
			        rnt = true;
			        ids += chks[i].value + ",";
			        ifids += chks[i].getAttribute("ifid") + ",";
			      }
		    }
	    }
	   
	    if(!rnt){
	      	  alert("请选择审核未通过的信息");
	    }else if(confirm("确定审核未通过")){
		      createHidden("ids", ids.substring(0,ids.length - 1));
		      createHidden("ifids",ifids.substring(0,ifids.length - 1));
		      
		      Ext.MessageBox.wait('提交处理过程中...');   
		      Ext.Ajax.request({       
			        //请求地址       
			       url: context + "/app/inforeplysh.do?method=reject",       
			       //提交参数组       
			       fileUpload: true,   
			       form: 'form2',   
			       scope: 'form2',     
			       //成功时回调       
			       success: function(response, options) {       
			           //获取响应的json字符串        
			           Ext.MessageBox.hide();
			           
			           var json = response.responseText;    
	                   var o = Ext.util.JSON.decode(json);
			           
			           if (o.success) {
						   alert("新闻评论审批未通过!");
						   handleRefresh();
	                   }else{
			               Ext.Msg.alert('提示', '提交设置新闻评论未通过失败!'); 
			           }                
			       }      
		     }); 
	    }
  }
  
  function handleQuery(){
      document.form1.action = context + "/app/inforeplysh.do?method=list";
      document.form1.submit();
  }
  
  function handleDeletes(){
	    var rnt = false;
	    var ids = "";
	    var ifids = "";
	    var status = "";
	    var chks = document.getElementsByTagName("input");
	    for(var i=0;i<chks.length;i++){
	      if(chks[i].type == "checkbox" && chks[i].checked){
	        rnt = true;
	        ids += chks[i].value + ",";
	        ifids += chks[i].getAttribute("ifid") + ",";
	        status += chks[i].getAttribute("istatus") + ",";
	      }
	    }
	    
	    if(!rnt){
	      alert("请选择要删除的新闻评论");
	    }else if(confirm("确定删除")){
	      createHidden("ids",ids.substring(0,ids.length - 1));
	      createHidden("ifids",ifids.substring(0,ifids.length - 1));
	      createHidden("status",status.substring(0,status.length - 1));
	      
	      document.form1.action = "<%=context%>/app/inforeplysh.do?method=delete";
	      document.form1.submit();
	    }
  }
  
  function responseResult(ids, names){
      $('qdirecarea').innerHTML = "专题栏目 : " +  names;
  }
</script>
<body>
<form id="form2" name="form1" method="post" action="">
<input type="hidden"
	name="pageNO" value="<%=pageNO%>">
				<div align="left" style="padding-left:5px;margin-top:15px;">
				<span id="qdirecarea"><%if(!qdirec.equals("")){ %>所属栏目 : <%=qdirec%><%} %></span>&nbsp;
				<img src="<%=context %>/app/info/images/search.png" title="查询新闻相关评论" style="cursor:hand;margin-bottom:-4px;" onclick="javascript:queryInfo(false);"/>查询
				<img src="<%=context %>/app/info/images/page_gear.png" title="新闻评论审核通过,可以发布" style="cursor:hand;margin-bottom:-4px;" onclick="javascript:handleOK();"/>审核通过
				<img src="<%=context %>/app/info/images/page_white_delete.png" title="新闻评论审核未通过,不能发布" style="cursor:hand;margin-bottom:-4px;" onclick="javascript:handleKO();"/>审核未通过
				<img src="<%=context %>/app/info/images/delete.gif" title="删除新闻评论" style="cursor:hand;margin-bottom:-4px;" onclick="javascript:handleDeletes();"/>删除
				<input type="hidden" id="qdirec" name="qdirec" value="<%=qdirec%>"/>
				<input type="hidden" id="qdirecid" name="qdirecid" value="<%=qdirecid%>"/>
				<input type="hidden" id="qname" name="qname" value="<%=qname%>"/>
				<input type="hidden" id="qstatus" name="qstatus" value="<%=qstatus %>"/>
				<input type="hidden" id="qdate" name="qdate" value="<%=qdate%>"/>
				</div>
				<table class="tbl" align="center" width="98%">
					<thead>
					<tr>
						<td title="全部选择/取消选择" onclick="javascript:checkall();" align="center">选择</td>
						<td 
							width="25%" align="center">&nbsp;<font color="#4C4C4C"><b>评论内容</b></font></td>
						<td 
							width="10%" align="center">&nbsp;<font color="#4C4C4C"><b>评论人</b></font></td>
						<td 
							width="10%" align="center">&nbsp;<font color="#4C4C4C"><b>IP</b></font></td>
						<td 
							width="15%" align="center">&nbsp;<font color="#4C4C4C"><b>评论时间</b></font></td>
						<td
							width="20%" align="center">&nbsp;<font color="#4C4C4C"><b>相关新闻</b></font></td>	
						<td
							width="10%" align="center">&nbsp;</td>
					</tr>
					</thead>
					<tbody>
					<%
							if (resultList != null && !resultList.isEmpty()) {
							for (int i = 0; i < resultList.size(); i++) {
								Map info = (Map) resultList.get(i);
								String number = (String) info.get("PAGINATION_NUMBER");
								String title = HTMLTool.htmlEscape((String) info
								.get("IF_TITLE"));
								String content = (String) info.get("RCONTENT");
								String ip = (String) info.get("RIP");
								String date = (String) info.get("RTIME");
								String username = (String) info.get("USER_NAME");
								String id = (String) info.get("PKID");
								String ifid = (String) info.get("IF_ID");
								String status = (String) info.get("RSTATUS");
								
								String bgcolor = "#ffffff";
								String statusLabel = "评论待审核";
								
								if(status.equals("1")){
									bgcolor = "#99CC66";
									statusLabel = "评论已审核通过";
								}else if(status.equals("-1")){
									bgcolor = "#dddddd";
									statusLabel = "评论未通过审核";
								}
					%>
					<tr onMouseOver="javascript:this.bgColor='#ffff99'"
						onmouseout=" javascript:this.bgColor='#ffffff'" >
						<td align="center" valign="top" bgColor="<%=bgcolor %>" title="<%=statusLabel %>"><input type="checkbox" name="chk" value="<%=id%>" ifid="<%=ifid %>" istatus="<%=status %>">&nbsp;<%=number%>
						</td>
						<td><div class="listtitle" style="width:220px;" title="<%=HTMLTool.htmlEscape(content, true, true, true, false)%>"><%=HTMLTool.htmlEscape(content, true, true, true, false)%></div></td>
						<td align="center">&nbsp;<%=username%></td>
						<td align="center"><%=ip%></td>
						<td align="center">&nbsp;<%=DateTrimmer.getYMDHMS_LBL(date)%></td>
						<td align="center"><div class="listtitle" style="width:150px;" title="<%=title%>"><a target="_blank" class="ititle"
							href="<%=context%>/app/info.do?method=viewinfo&id=<%=ifid%>"><%=title%></a></div></td>
						<td align="center"><%if(status.equals("0") || status.equals("-1")){ %><a
							href="javascript:void(0);" class="ititle" onclick="javascript:handleOK('<%=id%>', '<%=ifid%>');">通过</a><%} %>
							<%if(status.equals("0") || status.equals("1")){ %><a
							href="javascript:void(0);" class="ititle" onclick="javascript:handleKO('<%=id%>', '<%=ifid%>');">拒绝</a><%} %>
						</td>
					</tr>
					<%
						}
						}
					%>
					</tbody>
				</table>
				<div id="pager"><div style="float:left;padding-left:5px;"><%=label.displayLabel()%>
					</div> <div style="float:right;padding:5px;"><%=label.startLabel()%> <%=label.previousLabel()%>
						<%=label.nextLabel()%> <%=label.endLabel()%> 
				<%=controller.getController().toString()%></div>
				</div>
				<%=controller.getControlScript(true)%>
</form>
</body>
</html>
